
/* 
 * Since 2008 - 2012
 */
package com.hh.bss.interfaces.controller;

import static com.hh.bss.util.extjs.JsonHelper.outJson;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.ModelAndView;


import com.hh.bss.auth.client.OnlineManager;
import com.hh.bss.auth.client.OnlineUser;
import com.hh.bss.auth.dao.*;
import com.hh.bss.auth.entity.*;
import com.hh.bss.auth.service.*;
import com.hh.bss.auth.vo.query.*;
import com.hh.bss.base.*;
import com.hh.bss.common.cache.SystemRoleResourceCache;
import com.hh.bss.common.cache.SystemUserCache;
import com.hh.bss.common.page.*;
import com.hh.bss.common.page.impl.*;
import com.hh.bss.project.entity.ContractJob;
import com.hh.bss.project.service.ContractJobService;
import com.hh.bss.project.vo.query.ContractJobQuery;
import com.hh.bss.util.*;
import com.hh.bss.util.extjs.ExtJsPageHelper;
import com.hh.bss.util.extjs.JsonHelper;
import com.hh.bss.util.extjs.ListRange;

import java.util.*;





@Controller
public class JobController extends BaseSpringController{
	//默认多列排序,example: username desc,createTime asc
	protected static final String DEFAULT_SORT_COLUMNS = null; 
	
private ContractJobService contractJobService;
	
	private ContractJob contractJob;


	
	
	/** 通过spring自动注入 */
	public void setContractJobServiceImpl(ContractJobService service) {
		this.contractJobService = service;
	}	

	public void jobQuery(HttpServletRequest request,HttpServletResponse response,ContractJobQuery contractJobQuery) throws IOException
	{
		
		PageRequest<Map> pr = ExtJsPageHelper.createPageRequestForExtJs(request, DEFAULT_SORT_COLUMNS);
		Page page = contractJobService.findPage(contractJobQuery);
		
		List<ContractJob> ContractJoblist = (List) page.getResult();
		ListRange<ContractJob> resultList = new ListRange<ContractJob>();
		resultList.setRows(ContractJoblist);
		resultList.setTotal(page.getTotalCount());
		resultList.setMessage("ok");
		resultList.setSuccess(true);
		outJson(response,resultList);
	}
	
	public void jobDetail(HttpServletRequest request,HttpServletResponse response,ContractJob contractJob) throws IOException
	{
		Map<String, Object> result = new HashMap<String, Object>();
		try
		{
			ContractJob oldContractJob = (ContractJob)contractJobService.getById(contractJob.getId());
                         
			
            //取招聘岗位
			
			if(oldContractJob!=null) result.put("data", oldContractJob);
			result.put("success", true);
			result.put("msg", "成功!");
		}
		catch (Exception e)
		{
			result.put("failure", true);
			result.put("msg", e.getMessage());
			e.printStackTrace();
		}
		outJson(response,result);
	}

	
	
}
